<?
require_once("cls_db.php");

class utility
{

	function set_numrows($num)
	{
		$this->numrows	= $num;
	}

	function set_pagename($str)
	{
		$this->pagename	= $str;
	}

	function set_lastpage($num)
	{
		$this->lastpage	= $num;
	}

	function set_qrystr($str)
	{
		$this->qrystr	= $str;
	}

	function set_pageno($num)
	{
		$this->pageno	= $num;
	}

	function chk_login()
	{
		//echo ROOTPATH;
		if (empty($_SESSION['username'])) {
			header ("Location: login.php");
		}
	}

	function paging($pagename,$pagecount,$numrows,$qrystr,$pageno)
	{
		if ($numrows==0) {
			echo "<h5>No Record to show!!!</h5>"; return; }

		if ($pageno <> 1)//For Previous
			echo "<a href ='$pagename?page=".($pageno-1).$qrystr."' class='main_text'>Prev</a>";
		else
			echo "Prev";

		for ($i=0; $i < $pagecount; $i++)
		{
			if ($i != ($pageno-1))
				echo " <a href='$pagename?page=".($i+1).$qrystr."' class='main_text'>".($i+1)."</a>";
			else
				echo " ".($i+1);
		}//for

		if ($pageno <> ($i)) //For Next
            echo " <a href ='$pagename?page=".($pageno+1).$qrystr."' class='main_text'>Next</a>";
        else
        	echo " Next";
	}//paging

	

}//class utility
?>